const express = require('express'); //引入express模块
const db = require('../db'); //引入user模块

//路由中间件
const router = express.Router();
module.exports = router;

router.get('/', async (req, res) => {
    const {
        name,
        password,
        mdl
    } = req.query;
    const sql = `select name,password from user where name='${name}' and password='${password}'`
    const data = await db(sql)
    if (data.length > 0) {
        res.send({
            code: 200,
            data: data[0]
        })
    } else {
        res.send({
            code: 400,
            data: []
        })
    }
})